﻿using System;



class GCDandLCM

{

    static void Main()

    {

        Console.WriteLine("递归实现的最大公约数和最小公倍数");



        Console.Write("请输入第一个正整数：");

        int m = int.Parse(Console.ReadLine());



        Console.Write("请输入第二个正整数：");

        int n = int.Parse(Console.ReadLine());



        if (m > 0 && n > 0)

        {

            int gcd = GCD_Recursive(m, n);

            int lcm = LCM(m, n, gcd);



            Console.WriteLine($"\n最大公约数 (GCD): {gcd}");

            Console.WriteLine($"最小公倍数 (LCM): {lcm}");

        }

        else

        {

            Console.WriteLine("请输入正整数！");

        }

    }

    static int GCD_Recursive(int a, int b)

    {

        if (b == 0)

            return a;

        return GCD_Recursive(b, a % b);

    }



    static int LCM(int a, int b, int gcd)

    {

        return Math.Abs(a * b) / gcd;

    }

}